<template>
  <div>
      <van-icon
      :color="value?'#ffa500':'#777'"
      :name="value?'star':'star-o'"
      @click="onClick" />
  </div>
</template>

<script>
import { addCollect, deleteCollect } from '@/api/article.js'
export default {
  name: 'CollectArticle',
  components: {},
  props: {
    value: Boolean,
    articleId: [String, Number, Object]
  },
  methods: {
    async  onClick () {
      if (this.value) {
        await deleteCollect(this.articleId)
      } else {
        await addCollect(this.articleId)
      }
      this.$emit('input', !this.value)
      this.$toast.success('操作成功')
    }
  }
}
</script>

<style>

</style>